package com.xdxc.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xdxc.model.entity.ExamScoringTask;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface ExamScoringTaskMapper extends BaseMapper<ExamScoringTask> {

    @Select("SELECT * FROM exam_scoring_task " +
            "WHERE status = 1 " +      // 处理中
            "AND update_time < #{timeoutTime} " +
            "AND retry_count < #{maxRetry} " +
            "ORDER BY create_time ASC")
    List<ExamScoringTask> selectTimeoutTasks(
            @Param("timeoutTime") LocalDateTime timeoutTime,
            @Param("maxRetry") int maxRetry);
}